#ifndef __IIC_H__
#define __IIC_H__
#include "sys.h"
#define SCL PAout(11)
#define SDA PAout(12)
#define READ_SDA PAin(12)
#define SDA_IN() {GPIOA->CRH &= ~(0x000f0000);GPIOA->CRH |= (0x00080000);}
#define SDA_OUT() {GPIOA->CRH &= ~(0x000f0000);GPIOA->CRH |= (0x00030000);}

void IIC_Init(void);
void IIC_Start(void);
void IIC_Stop(void);
void IIC_Ack(void);
void IIC_NAck(void);
unsigned char IIC_Wait_Ack(void);
void IIC_Send_Byte(unsigned char txd);
unsigned char IIC_Read_Byte(unsigned char ack);
unsigned char Single_WriteIIC(unsigned char SlaveAddress,unsigned char REG_Address,unsigned char REG_data);
unsigned char Single_ReadIIC(unsigned char SlaveAddress,unsigned char REG_Address);
unsigned char I2C_Read_MultiBytes(unsigned char SlaveAddress, unsigned char REG_Address, unsigned char BytesNum, unsigned char *buf);
unsigned char I2C_Write_MultiBytes(unsigned char SlaveAddress, unsigned char REG_Address, unsigned char BytesNum, const unsigned char *buf);
#endif
